﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MongoDB.Driver;
using MongoDB.Driver.Builders;
using MongoDB.Driver.GridFS;
using MongoDB.Driver.Linq;
using System.Configuration;

namespace Microhard.Core.DBUtility
{
    public class MongoDBOprator<T> : ICacheOperator<T>
    {
        protected MongoDatabase _db = null;
        protected MongoCollection _coll = null;

        public MongoDBOprator(string databaseName, string collectionName)
        {
            string connectionString = ConfigurationManager.AppSettings["mongodbCnn"];
            try
            {
                var mc = new MongoClient();
                var server = mc.GetServer();
                _db = server.GetDatabase(databaseName);
                _coll = _db.GetCollection<T>(collectionName);
            }
            catch (Exception ex)
            {
                Log.Error("MongoDBOprator初始化失败", ex);
            }
        }

        public virtual void UpdateCache(string key, T newModel)
        {
            throw new NotImplementedException();
        }

        public virtual T GetFromCache(string key)
        {
            throw new NotImplementedException();
        }

        public virtual void RemoveFormCache(List<string> keys)
        {
            throw new NotImplementedException();
        }

        public virtual void RefreshCache()
        {
            throw new NotImplementedException();
        }
    }
}
